{% extends 'CouponBundle:Coupon:layout.html.twig' %}

{% block title %}优惠码管理 - {{ parent() }}{% endblock %}

{% set menu = 'coupon_batch' %}

{% set script_controller = 'couponbundle/controller/coupon/list' %}

{% block main %}
  {{ web_macro.flash_messages() }}
  <div class="page-header clearfix">
    <a href="{{ path('admin_coupon_generate') }}" class="btn btn-info btn-sm pull-right" id="generate-coupon-btn">生成优惠码</a>
    <h1 class="pull-left">优惠码批次管理</h1>
  </div>

  <form id="coupon-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="form-group">
      <select class="form-control" name="type">
        {{ select_options(dict('couponType'), app.request.query.get('type'), '按优惠方式') }}
      </select>
    </div>
    <div class="form-group">
      <input class="form-control" type="text" placeholder="名称关键字" name="name" value="{{ app.request.get('name') }}">
    </div>
    <button class="btn btn-primary">检索</button>
  </form>

  <table class="table table-striped" id="coupon-list">
    <thead>
      <tr>
        <th>优惠码名称</th>
        <th>优惠内容</th>
        <th>生成数量</th>
        <th>已使用</th>
        <th>已优惠金额</th>
        <th>有效期至</th>
        <th>生成时间</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      {% for batch in batchs %}
        {% include 'CouponBundle:Coupon:tr.html.twig' %}
      {% else %}
        <tr class="empty"><td colspan="20">无优惠码记录</td></tr>
      {% endfor %}
    </tbody>
  </table>
  {{ web_macro.paginator(paginator) }}
{% endblock %}
